/*
 * Copyright © 2017 eqxiu.com 北京中网易企秀科技有限公司  All rights reserved.
 */
package cn.hermit.data.json.validator;

import cn.hermit.data.exception.ValidationException;

/**
 * 
 * JSON Validator used for validate or adjust JSON string in validator chain.
 * 
 * <p>
 * Sometimes, JSON string need to be validated or the characters in 
 * JSON string need to be adjusted for some use case.
 * It provides methods to validate keys and values.
 * The <tt>Validator</tt> also provide a chain to for a serious of validation.
 * </p>
 * 
 * @see ValidatorChain
 * @author Jack Gao (Chinese name : GAO JIANGUO, Email : linux.gjg@gmail.com)
 * @date 18 Jun, 2014
 */
public interface Validator {

	/**
	 * Validate JSON key
	 * 
	 * @param key
	 * 		JSON Key string
	 * @return
	 * 		Adjusted JSON key string
	 * @throws ValidationException
	 * 		If the validation failed, throw such exception
	 */
	String validateKey(String key) throws ValidationException;

	/**
	 * Validate JSON value
	 * 
	 * @param value
	 * 		JSON value
	 * @return
	 * 		Adjusted JSON value
	 * @throws ValidationException
	 * 		If the validation failed, throw such exception
	 */
	Object validateValue(Object value) throws ValidationException;

}